/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-04-04
 * Time:17:13
 */

/**
 * JZ5 替换空格
 */
public class replaceSpace {
    public static void main(String[] args) {
        System.out.println(replaceSpace("We Are Happy"));
    }
    public static String replaceSpace (String s) {
        // write code here
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (s.charAt(i) != ' '){
                stringBuilder.append(s.charAt(i));
            }else {
                stringBuilder.append("%20");
//                i++;
            }
        }
        return stringBuilder.toString();
    }
}
